﻿package org.xhs.report.doc.utils
{
    import __AS3__.vec.*;
    import baidu.wenku.common.utils.*;
    import baidu.wenku.doc.ui.*;
    import flash.events.*;

    public class DocPageFlip extends EventDispatcher
    {
        protected var turnLeft:Boolean = true;
        protected var curPageth:int;
        protected var curPage:BlankPage = null;
        protected var cur2Pageth:int;
        protected var cur2Page:BlankPage = null;
        protected var nextPageth:int;
        protected var nextPage:BlankPage = null;
        protected var next2Pageth:int;
        protected var next2Page:BlankPage = null;
        protected var _storePage:BlankPage;
        protected var _pagesArray:Vector.<BlankPage>;
        protected var _pageFlip:PageFlip;

        public function DocPageFlip()
        {
            return;
        }// end function

        public function flip(param1:int, param2:int, param3:Boolean = true) : void
        {
            if (!this._pageFlip)
            {
                this._pageFlip = new PageFlip();
            }
            this.turnLeft = param3;
            if (this.turnLeft)
            {
                this.turnLeft = true;
                this.curPageth = int(Math.floor(param2 / 2) * 2 + 1);
                this.cur2Pageth = int(Math.floor(param2 / 2) * 2);
                this.nextPageth = int(Math.floor(param1 / 2) * 2);
                this.next2Pageth = int(Math.floor(param1 / 2) * 2 + 1);
            }
            else
            {
                this.turnLeft = false;
                this.curPageth = int(Math.floor(param2 / 2) * 2);
                this.cur2Pageth = int(Math.floor(param2 / 2) * 2 + 1);
                this.nextPageth = int(Math.floor(param1 / 2) * 2 + 1);
                this.next2Pageth = int(Math.floor(param1 / 2) * 2);
            }
            var _loc_4:* = this.pagesArray.length;
            if (this.curPageth >= 0 && this.curPageth < _loc_4)
            {
                this.curPage = this.pagesArray[this.curPageth] as BlankPage;
                this.curPage.showLoading();
            }
            if (this.nextPageth >= 0 && this.nextPageth < _loc_4)
            {
                this.nextPage = this.pagesArray[this.nextPageth] as BlankPage;
                this.nextPage.showLoading();
            }
            if (this.cur2Pageth >= 0 && this.cur2Pageth < _loc_4)
            {
                this.cur2Page = this.pagesArray[this.cur2Pageth] as BlankPage;
                this.cur2Page.showLoading();
            }
            if (this.next2Pageth >= 0 && this.next2Pageth < _loc_4)
            {
                this.next2Page = this.pagesArray[this.next2Pageth] as BlankPage;
                this.next2Page.showLoading();
            }
            this._pageFlip.flip(this.curPage, this.nextPage, this.cur2Page, this.next2Page, this.turnLeft);
            return;
        }// end function

        public function unload() : void
        {
            this._pageFlip.unload();
            return;
        }// end function

        public function set pagesArray(param1:Vector.<BlankPage>) : void
        {
            this._pagesArray = param1;
            return;
        }// end function

        public function get pagesArray() : Vector.<BlankPage>
        {
            return this._pagesArray;
        }// end function

        public function get storePage() : BlankPage
        {
            return this._storePage;
        }// end function

        public function set storePage(param1:BlankPage) : void
        {
            this._storePage = param1;
            return;
        }// end function

    }
}
